package kr.hkit.androidcomplete03.ch26;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ProductDBHelper extends SQLiteOpenHelper {

	public ProductDBHelper(Context context) {
		super(context, ProductFrameWork.DB_NAME, null, ProductFrameWork.DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(ProductFrameWork.CREATE_TBL);
		for(int i=0; i < ProductFrameWork.INSERT_DATA.length; i++){
			db.execSQL(ProductFrameWork.INSERT_DATA[i]);
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(ProductFrameWork.DROP_TBL);
		onCreate(db);
	}

}
